import api from "@/api"
export default {
    state: {
        networkStatus: true, //网络是否通畅
        nav: {
            statusBarHeight: 0,
            navBarHeight: "44px",
            menuButtonRectWidth: 0
        },
        configData: uni.getStorageSync("configData") || ""
    },
    mutations: {
        //导航栏信息
        setNavBarHeight(state, payload) {
            state.nav = payload
        },
        //网络状态
        setNetworkStatus(state, flag) {
            state.networkStatus = flag
        },
        //公用配置信息
        setConfig(state, { industries, ...data }) {
            this.commit("setMerchantEnums", industries)
            uni.setStorageSync("configData", data)
            state.configData = data
        }
    },
    actions: {
        getConfig({ commit }) {
            return new Promise((resolve, reject) => {
                api.getConfig().then(res => {
                    commit("setConfig", res)
                    resolve(res)
                })
            })
        }
    }
}
